<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class OrderController extends Controller
{
   /*
        订单列表
   */
        public function getIndex(Request $request)
        {   
            //获取每页显示几条
            $num = $request->input('num',10);
            //判断是否有查询条件
            if($request->input('keywords')){
                $orders = DB::table('shop_orders')->where('title','like','%'.$request->input('keywords').'%')->paginate($num);
            }else{
                $orders = DB::table('shop_orders')->paginate($num);
            }

            //获取参数列表
            $list = $request->all();
          
            //解析模板 根目录为resources下的views
            return view('admin.order.index',['orders'=>$orders,'list'=>$list]);
        }
        
        /*
            封装方法 进行ajax删除操作
        */
        public function postDelete(Request $request)
        {
            // echo 'delete';
            $oid = $request->input('oid');
            //删除用户
            
            $res = DB::delete("delete from shop_orders where oid=".$oid);
            echo $res;
        }
     	
}
